import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const baseRouters = [
    {
        path: '/',
        redirect: '/apps'
    },
    {
        path: '/test',
        name: 'test',
        component: () => import('../view/test/index.vue')
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('../view/login/login.vue')
    },
    {
        path: '/',
        component: () => import('../view/layout/layout'),
        children: [{
            path: 'userList',
            name: 'userList',
            meta: {title: '用户列表'},
            component: () => import('../view/user/userList')

        }, {
            path: 'apps',
            name: 'apps',
            meta: {title: '应用列表'},
            component: () => import('../view/apps/index'),
            children: [
                {
                    path: '',
                    component: () => import('../view/apps/list/appList.vue')
                },
                {
                    path: 'deploy',
                    name: 'deploy',
                    props: route => ({appName: route.query.appName}),
                    meta: {title: '应用部署', appSwitch: true},
                    component: () => import('../view/apps/deploy/deploy.vue')
                },
                {
                    path: 'logsearch',
                    name: 'logsearch',
                    props: route => ({appName: route.query.appName}),
                    meta: {title: '应用日志', appSwitch: true},
                    component: () => import('../view/apps/logsearch/logsearch.vue')
                },
                {
                    path: 'build',
                    name: 'build',
                    props: route => ({appName: route.query.appName}),
                    meta: {title: '应用构建', appSwitch: true},
                    component: () => import('../view/apps/build/build.vue')
                },
                {
                    path: 'monitor',
                    name: 'monitor',
                    props: route => ({appName: route.query.appName}),
                    meta: {title: '应用监控', appSwitch: true},
                    component: () => import('../view/apps/monitor/monitor.vue')
                },
                {
                    path: 'dbquery',
                    name: 'dbquery',
                    props: route => ({appName: route.query.appName}),
                    meta: {title: '数据查询', appSwitch: true},
                    component: () => import('../view/apps/database/dbquery.vue')
                },
                {
                    path: 'sqlTaskList',
                    name: 'sqlTaskList',
                    props: route => ({appName: route.query.appName}),
                    meta: {title: '数据上线', appSwitch: true},
                    component: () => import('../view/apps/database/sqlTaskList.vue')
                },
                {
                    path: 'sqlTaskExec',
                    name: 'sqlTaskExec',
                    meta: {title: '数据上线申请'},
                    component: () => import('../view/apps/database/sqlTaskExec.vue')
                }]
        }, {
            path: '/apply',
            name: 'apply',
            meta: {title: '上线申请'},
            component: () => import('../view/apply/index'),
            children: [
                {
                    path: 'applyList',
                    name: 'applyList',
                    meta: {title: '申请列表'},
                    component: () => import('../view/apply/applyList/list')
                },
                {
                    path: 'applyStepForm',
                    name: 'applyStepForm',
                    meta: {title: '提交申请'},
                    component: () => import('../view/apply/applyForm/applyStepForm')
                },
                {
                    path: 'applyDetailForm/:applyId',
                    name: 'applyDetailForm',
                    props: true,
                    meta: {title: '应用上线申请'},
                    component: () => import('../view/apply/applyForm/applyDetailForm')
                },
                {
                    path: 'databaseApplyForm/:applyId?',
                    name: 'databaseApplyForm',
                    props: true,
                    meta: {title: '数据上线申请'},
                    component: () => import('../view/apply/applyForm/databaseApplyForm')
                },
                {
                    path: 'applyAuditForm/:applyId',
                    name: 'applyAuditForm',
                    props: true,
                    meta: {title: '审核详情'},
                    component: () => import('../view/apply/applyForm/applyDetailForm')
                },
                {
                    path: 'auditList',
                    name: 'auditList',
                    props: true,
                    meta: {title: '审核列表'},
                    component: () => import('../view/apply/auditList/list')
                }]
        }, {
            path: '/manage',
            name: 'manage',
            meta: {title: '系统管理'},
            component: () => import('../view/manage/index'),
            children: [
                {
                    path: 'appList',
                    name: 'appList',
                    meta: {title: '应用列表'},
                    component: () => import('../view/manage/appList/appList')
                }, {
                    path: 'hostList',
                    name: 'hostList',
                    meta: {title: '主机列表'},
                    component: () => import('../view/manage/hostInstanceList/list')
                }, {
                    path: 'appInstanceList',
                    name: 'appInstanceList',
                    meta: {title: '应用实例列表'},
                    component: () => import('../view/manage/appInstanceList/list')
                }, {
                    path: 'databaseList',
                    name: 'databaseList',
                    meta: {title: '应用实例列表'},
                    component: () => import('../view/manage/databaseInstanceList/list')
                }, {
                    path: 'system',
                    name: 'system',
                    meta: {title: '系统配置'},
                    component: () => import('../view/manage/system/system')
                }]
        }]
    },
]
const createRouter = () => new Router({
    routes: baseRouters
})

const router = createRouter()

export default router